package org.nettyServer.eunm;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.nettyServer.command.login.CS_Login;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@AllArgsConstructor
@Getter
public enum EMessageCode {
    LOGIN("0001","登录"), //登录
    HEARTBEAT("0002","心跳"),//心跳



    ;
    private final String code;
    private final String type;

    //根据code获取枚举类型
    public static String getEnumByCode(String code) {
        for (EMessageCode e : EMessageCode.values()) {
            if (e.getCode().equals(code)) {
                return e.type;
            }
        }
        return null;
    }
    public static List<String> getCodeList() {
        EMessageCode[] values = EMessageCode.values();
        return Arrays.stream(values).map(EMessageCode::getCode).collect(Collectors.toList());
    }
}
